package com.gzx.qc.modular.keyword.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzx.qc.modular.keyword.entity.bo.GzxQaKeywordAddOrEditBo;
import com.gzx.qc.modular.keyword.entity.bo.GzxQaKeywordQueryBo;
import com.gzx.qc.modular.keyword.entity.vo.GzxQaKeywordVo;
import com.gzx.qc.modular.keyword.service.GzxQaKeywordService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import vip.xiaonuo.common.pojo.CommonResult;

/**
 * @author zjt
 * @description
 * @date 2025/2/5 10:37
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/qc/keyword")
public class GzxQaKeywordController {

    private final GzxQaKeywordService qaKeywordService;

    /**
     * 分页查询关键词
     *
     * @param qaKeywordQueryBo 查询条件
     * @return
     */
    @PostMapping("/pageList")
    public CommonResult<Page<GzxQaKeywordVo>> pageList(@RequestBody GzxQaKeywordQueryBo qaKeywordQueryBo) {
        return CommonResult.data(qaKeywordService.pageList(qaKeywordQueryBo));
    }

    /**
     * 新增关键词
     *
     * @param qaKeywordAddOrEditBo
     * @return
     */
    @PostMapping("/add")
    public CommonResult<Void> add(@RequestBody GzxQaKeywordAddOrEditBo qaKeywordAddOrEditBo) {
        qaKeywordService.addOrEdit(qaKeywordAddOrEditBo);
        return CommonResult.ok();
    }

    /**
     * 修改关键词
     *
     * @param qaKeywordAddOrEditBo
     * @return
     */
    @PostMapping("/edit")
    public CommonResult<Void> edit(@RequestBody GzxQaKeywordAddOrEditBo qaKeywordAddOrEditBo) {
        qaKeywordService.addOrEdit(qaKeywordAddOrEditBo);
        return CommonResult.ok();
    }

    /**
     * 修改关键词
     *
     * @param id
     * @return
     */
    @GetMapping("/del/{id}")
    public CommonResult<Void> del(@PathVariable("id") Long id) {
        qaKeywordService.del(id);
        return CommonResult.ok();
    }

    /**
     * 修改关键词
     *
     * @param multipartFile
     * @return
     */
    @PostMapping("/importExcel")
    public CommonResult<Void> importExcel(MultipartFile multipartFile) {
        qaKeywordService.importExcel(multipartFile);
        return CommonResult.ok();
    }
}
